import 'dart:convert';

import 'package:flutter/material.dart';
import 'NewsPage.dart';
import 'video_page.dart';
import 'mine_page.dart';

class TabNaviPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new TabNaviPageState();
  }
}

class TabNaviPageState extends State {
  var _currentIndex = 0;
  PageController _pageController = new PageController();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PageView(
        children: <Widget>[
          NewsPage(),
          VideoPage(),
          MinePage(),
        ],
        controller: _pageController,
        onPageChanged: (int index) {
          setState(() {
            _currentIndex = index;
          });
        },
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: <BottomNavigationBarItem>[
          new BottomNavigationBarItem(
              icon: Icon(Icons.home), title: Text('首页')),
          new BottomNavigationBarItem(
              icon: Icon(Icons.videocam), title: Text('视频')),
          new BottomNavigationBarItem(
              icon: Icon(Icons.people), title: Text('我的'))
        ],
        currentIndex: _currentIndex,
        onTap: (int index) {
          setState(() {
            _currentIndex = index;
            _pageController.animateToPage(index,
                duration: const Duration(milliseconds: 300),
                curve: Curves.ease);
          });
        },
      ),
    );
  }
}
